# Copyright (c) 1994 Sun Wu, Udi Manber, Burra Gopal.  All Rights Reserved.

srcdir = @srcdir@
VPATH  = @srcdir@
SHELL  = /bin/sh
CC     = @CC@
AR     = @AR@
RANLIB = @RANLIB@
CP     = @CP@
STRIP  = @STRIP@
INSTALL		= @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA	= @INSTALL_DATA@
INSTALL_MAN	= ${INSTALL} -m 444
DEFS		=

prefix = @prefix@
exec_prefix = @exec_prefix@
binprefix =
manprefix =

bindir = $(exec_prefix)/bin
libdir = $(exec_prefix)/lib
mandir = $(prefix)/man/man1
manext = 1

MAN1		= agrep.1

# YOU DON'T HAVE TO CHANGE ANYTHING BELOW THIS LINE

# The binaries will be made in ../bin/. and the agrep library in ../lib
# You normally don't have to change them.
BINDIR	      = ../bin
LIBDIR	      = ../lib
TCOMP	      =	cast
TCOMPDIR      = ../compress
AGREPDIR      = ../agrep
TEMPLATEDIR   = ../libtemplate

# You can change the target to use the "cast" (compression) library by changing:
#	all: $(NOTCPROG)
# to:
#	all: $(PROG)
# You must also define DOTCOMPRESSED below to be 1 instead of 0.

DOTCOMPRESSED = 0

OPTIMIZEFLAGS	= -O2
INCLUDEFLAGS	= -I$(AGREPDIR) -I$(TEMPLATEDIR)/include

# AGREP_POINTER is defined in autoconf.h
MYDEFINEFLAGS	= -DMEASURE_TIMES=0 -DDOTCOMPRESSED=$(DOTCOMPRESSED)
CFLAGS		= $(MYDEFINEFLAGS) $(INCLUDEFLAGS) $(DEFS)
LDFLAGS		=
OTHERLIBS	=

PROG	      = agrep
NOTCPROG      = notc$(PROG)
LIB	      = $(LIBDIR)/lib$(PROG).a

all: $(LIB) $(NOTCPROG)

install: all install-man
	$(INSTALL) $(PROG) $(bindir)

install-man: $(MAN1)
	$(INSTALL_MAN) $(MAN1) $(mandir)

clean:
		rm -f $(LIB) $(OBJS) dummyfilters.o main.o core a.out $(PROG)

distclean:	clean
		rm -f Makefile

HDRS	      =	agrep.h checkfile.h re.h defs.h config.h
TCOMPLIBOBJ   = \
		$(TCOMPDIR)/hash.o \
		$(TCOMPDIR)/string.o \
		$(TCOMPDIR)/misc.o \
		$(TCOMPDIR)/quick.o \
		$(TCOMPDIR)/cast.o \
		$(TCOMPDIR)/uncast.o \
		$(TCOMPDIR)/tsimpletest.o \
		$(TCOMPDIR)/tbuild.o\
		$(TCOMPDIR)/tmemlook.o
OBJS	      =	\
		follow.o	\
		asearch.o	\
		asearch1.o	\
		agrep.o		\
		bitap.o		\
		checkfile.o	\
		compat.o	\
		maskgen.o	\
		parse.o		\
		checksg.o	\
		preprocess.o	\
		delim.o		\
		asplit.o	\
		recursive.o	\
		sgrep.o		\
		newmgrep.o	\
		utilities.o

$(PROG):	$(OBJS) main.o $(LIBDIR)/lib$(TCOMP).a
		$(CC) -L$(LIBDIR) $(LDFLAGS) -o $@ $(OBJS) main.o -l$(TCOMP) $(OTHERLIBS)
		$(AR) rcv $(LIB) $(OBJS) $(TCOMPLIBOBJ)
		$(RANLIB) $(LIB)

$(LIBDIR)/lib$(TCOMP).a:
		cd $(TCOMPDIR) ; $(MAKE)

$(LIB):	$(OBJS) dummyfilters.o
		$(AR) rcv $(LIB) $(OBJS) dummyfilters.o
		$(RANLIB) $(LIB)

$(NOTCPROG):	$(OBJS) dummyfilters.o main.o
		$(CC) $(LDFLAGS) -o $(PROG) $(OBJS) dummyfilters.o main.o $(OTHERLIBS)

compat.o:	agrep.h defs.h config.h
asearch.o:	agrep.h defs.h config.h
asearch1.o:	agrep.h defs.h config.h
bitap.o:	agrep.h defs.h config.h
checkfile.o:	agrep.h checkfile.h defs.h config.h
follow.o:	re.h agrep.h defs.h config.h
main.o:		agrep.h checkfile.h defs.h config.h dummysyscalls.c
agrep.o:	agrep.h checkfile.h defs.h config.h
newmgrep.o:	agrep.h defs.h config.h
maskgen.o:	agrep.h defs.h config.h
next.o:		agrep.h defs.h config.h
parse.o:	re.h agrep.h defs.h config.h
preprocess.o:	agrep.h defs.h config.h
checksg.o:	agrep.h checkfile.h defs.h config.h
delim.o:	agrep.h defs.h config.h
asplit.o:	agrep.h defs.h config.h
sgrep.o:	agrep.h defs.h config.h
abm.o:		agrep.h defs.h config.h
utilities.o:	re.h agrep.h defs.h config.h
dummyfilters.o:	dummyfilters.c
